package com.example.smartcity_poverty.ui.AllService.Attorneys.activity.AttMe.adapter

import android.content.Intent
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.model.Attreneys.AttMeListAllModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.AllService.Attorneys.activity.AttMe.activity.AttMeAllActivity
import kotlinx.android.synthetic.main.re_att_me_home_list.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *  我的咨询列表页面适配器
 **/
class AttMeListAdapter(
    val list: MutableList<AttMeListAllModel.RowsBean>,
    layoutId: Int
) : BaseRecyclerAdapter<AttMeListAllModel.RowsBean>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: AttMeListAllModel.RowsBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        list.sortByDescending { it -> it.createTime }

        val d = list[position]
        val fv = holder.viewFind
        val con = holder.viewFind.view?.context


        // 填充数据
        // glide(url + d.imageUrls, fv.attMeListUserImage)
        fv.attMeListUserName.text = d.lawyerName
        fv.attMeListUserYes.text = "法律专长: ${d.legalExpertiseName}"
        if (d.state.toString() == "0") fv.attMeListUserSize.text = "处理中..."
        if (d.state.toString() == "1") fv.attMeListUserSize.text = "已处理"
        fv.attMeListUserAll.text = "提交时间: ${d.createTime}"
        fv.attMeListUserYes.text = "法律专长: ${d.legalExpertiseName}"

        fv.attMeListUserBtnOk.setOnClickListener {
            con?.startActivity(
                Intent(con, AttMeAllActivity::class.java).putExtra(
                    "id",
                    d.id.toString()
                )
            )
        }
    }

}